export const invoicingSubjectState: {
	[key: string | number]: any
} = {
	1: {
		name: '审核中',
		color: 'processing'
	},
	2: {
		name: '不通过',
		color: 'error'
	},
	3: {
		name: '启用',
		color: 'success'
	},
	4: {
		name: '禁用中',
		color: 'default'
	}
}
export const reviewStatus: {
	[key: string | number]: any
} = {
	0: {
		name: '待审核',
		color: 'processing'
	},
	1: {
		name: '审核中',
		color: 'error'
	},
	2: {
		name: '不通过',
		color: 'success'
	}
}

/* 面积单位 */

export const areaUnitList: any[] = [
	{
		name: '平方千米',
		id: '平方千米'
	},
	{
		name: '平方米',
		id: '平方米'
	},
	{
		name: '公顷',
		id: '公顷'
	},
	{
		name: '亩',
		id: '亩'
	},
	{
		name: 'h ㎡',
		id: 'h ㎡'
	},
	{
		name: 'k ㎡',
		id: 'k ㎡'
	},
	{
		name: '㎡',
		id: '㎡'
	}
]

/* 是否跨市 */
export const isCrossCity: any[] = [
	{
		name: '是',
		id: 1
	},
	{
		name: '否',
		id: 0
	}
]

export const equipmentList: any[] = [
	{
		name: '金税盘/税控盘',
		id: 1
	},
	{
		name: '税务 UKEY',
		id: 2
	},
	{
		name: '全电发票',
		id: 5
	}
	// {
	// 	name: '虚拟设备',
	// 	id: 3
	// },
	// {
	// 	name: '区块链发票',
	// 	id: 4
	// }
]
export const equipmentData: any = {
	1: '金税盘/税控盘',
	2: '税务 UKEY',
	5: '全电发票'
}
export const equipmentType: {
	[key: string | number]: any
} = {
	1: {
		name: '金税盘/税控盘',
		color: 'processing'
	},
	2: {
		name: '税务 UKEY',
		color: 'success'
	},
	3: {
		name: '虚拟设备',
		color: 'error'
	},
	4: {
		name: '区块链发票',
		color: 'default'
	},
	5: {
		name: '全电发票',
		color: 'default'
	}
}

export const invoicingInfo: {
	[key: string | number]: any
} = {
	1: {
		name: '启用',
		color: 'success'
	},
	2: {
		name: '禁用中',
		color: 'default'
	}
}
/**
 * 部门
 */
export interface Department {
	id?: string | null
	pid?: string | null
	level?: number | null
	name?: string | null
	deptNo?: string | null
	orderIndex?: number | null
	childList?: Department[] | null
}

export interface feeSubjectIds {
	id: string | number | null
	name: string | null
}
export interface orgItemInfo {
	drawerName?: string | null
	extensionNum?: string | null
	feeSubjectIds: feeSubjectIds[] | null
	id?: string | null
	invOrgId?: string | null
	isDefault?: true
	machineCode?: string | null
	reviewerName?: string | null
	sellerAddress?: string | null
	sellerBankAccount?: string | null
	sellerBankName?: string | null
	sellerTel?: string | null
	takerName?: string | null
}

/**
 * 发票信息
 */
export interface invoiceInfo {
	departmentId?: string | null
	disabledFeeSubjectId?: string[] | any | null
	disabledFeeSubjectIds?: feeSubjectIds[] | any | null
	orgItemList?: orgItemInfo[] | null

	// 开票设备类型:
	deviceType: string[] | any | null
	// 主体是否存在不动产租赁服务相关的税收分类编码
	existImmovables: number | string | null
	// 不动产所在地:省 市
	region: string | null
	// 不动产详细地址
	detailedAddress: string | null
	// 面积单位
	areaUnit: string | null
	// 是否跨地(市)标志
	crossCitySign: number | string | null
	// 租赁开始日期
	leaseBeginDate: string | null
	// 租赁结束日期
	leaseEndDate: string | null
	// 产权证书/不动产权号
	titleNo: string | null
}
/**
 * 传入树型结构 id 返回子节点最后的orderIndex
 * @param tree
 * @returns
 */
export function getOrderIndex(tree: any, id: any): any {
	for (const data of tree) {
		if (data.id === id) {
			const index = data.childList.length - 1
			if (data.childList[index]) {
				return data.childList[index].orderIndex ? data.childList[index].orderIndex : 0
			}
			return 0
		}
		if (data.childList) {
			const findChildren: any = getOrderIndex(data.childList, id)
			if (findChildren) return findChildren
		}
	}
}
